/*
 * @Author: ૮₍ ˙О˙₎ა
 * @Date: 2023-05-02 15:19:48
 */
import { ajax } from "./ajax.js";

let aGo=document.querySelector('.go');

let inputs=document.querySelectorAll('input')
let strong=document.querySelector('strong')
aGo.onclick=function(e){
    let userName=inputs[0].value;
    let pwd=inputs[1].value;
    console.log(userName);
    
    if(userName==''||pwd===''){
        strong.style.display='block'
        strong.innerHTML='不能为空'
    }else{
        ajax.post('http://localhost/register',{userName,pwd},function(res){
            if(res.code){
                // 如果返回true表示用户名重复
                strong.style.display='block'
                strong.innerHTML='用户名重复'
            }else{
                window.location.assign('/login')
            }
        })
    }
    
    e.preventDefault()
}